package com.groupbuying.common.baseutils.baseframework4plugins.servicelocator;

import org.springframework.context.ApplicationContext;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @anthor zmlmagic
 * @date 2018/12/27 9:22 AM
 * @company 蒙泰互联网公司
 * @des 备注说明
 **/

public class ServiceLocator {
    private static ServiceLocator serviceLocator = null;
    private static Map<String, List<Object>> mapInitParams = new HashMap();
    private ApplicationContext ctx = null;

    private ServiceLocator() {
    }

    public static ServiceLocator getInstance(ApplicationContext context) {
        if ((serviceLocator == null || serviceLocator.ctx == null) && context != null) {
            serviceLocator = new ServiceLocator();
            serviceLocator.ctx = context;
        }

        return serviceLocator;
    }

    public static ServiceLocator getInstance() {
        return getInstance((ApplicationContext) null);
    }

    public ApplicationContext getCtx() {
        return this.ctx;
    }

    public static Map<String, List<Object>> getMapInitParams() {
        return mapInitParams;
    }

    public static void setMapInitParams(Map<String, List<Object>> mapInitParams) {
        mapInitParams = mapInitParams;
    }
}
